/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package control;

import java.io.IOException;
import java.util.ArrayList;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


/**
 *
 * @author farzin
 */
public class ExtractionDiscOferecIC {
    
     public static void main(String[] args) throws IOException {
        String url = "http://www.dac.unicamp.br/sistemas/horarios/grad/G1S0/IC.htm";
        print("Fetching %s...", url);

        Document doc = Jsoup.connect(url).get();
        Elements sigla = doc.select("a[href]");
        
        String href = doc.attr("abs:href");
        
        String[] s = sigla.text().split("  ");
        
        System.out.println(href);

            for (String src : s) {
               String[] s2 = src.split(" ", 2);
                print("%s -> %s\n",s2[0],s2[1]);
            }
         
        
    }

    private static void print(String msg, Object... args) {
        System.out.println(String.format(msg, args));
    }
    
    
}
